package com.flyu.myThread.lamada;

public class TestLamada1 {
    // 方式2：静态内部类
    static class Like2 implements ILike{
        @Override
        public void lamada() {
            System.out.println("I like lamada2");
        }
    }

    public static void main(String[] args) {
        ILike like;
        // 方式3：局部内部类
        class Like3 implements ILike{
            @Override
            public void lamada() {
                System.out.println("I like lamada3");
            }
        }

        like = new Like1();
        like.lamada();

        like = new Like2();
        like.lamada();

        like = new Like3();
        like.lamada();

        // 方式4：匿名内部类 没有类的名称,必须借助接口或父类
        like = new ILike() {
            @Override
            public void lamada() {
                System.out.println("I like lamada4");
            }
        };
        like.lamada();

        // 方式5：lamada简化
        like = () -> {
            System.out.println("I like lamada5");
        };
        like.lamada();
    }
}

// 函数式接口
interface ILike{
    void lamada();
}

// 方式1：接口类
class Like1 implements ILike{

    @Override
    public void lamada() {
        System.out.println("I like lamada1");
    }
}